//
// Created by tan on 22-8-20.
//

#include <iostream>
#include "DataCtrl.h"
#include "basedata.h"

using namespace std;

string getCurPath() {
    string mainPath = __FILE__;
    string curOs;
#ifdef __WIN32__
    curOs = "windows";
#elif __linux__
    curOs = "linux";
#elif __APPLE__
    curOs =  "apple";
#endif

    auto chr = Tools::split(mainPath, "/");
    string path;
    for (int i = 0; i < chr.size() - 1; ++i) {
        if (chr[i].empty()) {
            continue;
        }
        path += chr[i] + "/";
    }
    if (curOs == "windows") {
        return path;
    }
    return "/" + path;
}


int main() {
    auto path = getCurPath();

    string lineFilePath = path + "gerberFiles/gts-orig_lines_new.csv";

    DataCtrl dc;

    dc.readLines(lineFilePath);

    auto tmp = dc.getPointNoByXY(4.761115254717, -25.8711540306722);
    cout << tmp << endl;
    int bn = dc.getBlockNoByLineNo(993);
    cout << bn << endl;
    auto lns = dc.getLineNosByBlockNo(3);
    printSet(lns);
    dc.genDataObj();

    auto ln = dc.getLineNosByPointNo(122);
    cout << "---" << endl;
    printSet(ln);

    cout << dc.allPoints.size() << endl;
    cout << dc.allLines.size() << endl;
    cout << dc.allPads.size() << endl;
    cout << dc.allSurfaces.size() << endl;
    cout << "***************************" << endl;
    auto ps = dc.pointsBetween(-91.0082, -29.2354, -91.0082, -25.5646);
    for (const auto &item: ps) {
        cout << item.pointNo << ": " << item.xCoord << ", " << item.yCoord << endl;
    }
    createSGPoints(dc);
    auto clns = SGLines(dc);
    auto cur = clns.nIdx[1145];
    cout << "=>>>>" << cur.allPoints.size() << endl;
    return 0;
}